package com.koron.css2.newProjectCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * 用户工程节点延期
 * @author amdin
 * @since 2021-06-04
 * @version 2.1
 *
 */
public class PjTimePostpone implements ServerInterface{

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		/*try {
			PjProcessNodeTimePostponeBean processNodeTimePostpone = JsonUtils.objectToPojo(req.getData(), PjProcessNodeTimePostponeBean.class);
			if(processNodeTimePostpone.getTimeOut() == null) {
				return MessageBean.create(Constant.MESSAGE_INT_FAIL, "延期时间不能为空", Void.class);
			}
			if(StringUtils.isEmpty(processNodeTimePostpone.getComments())) {
				return MessageBean.create(Constant.MESSAGE_INT_FAIL, "延期说明不能为空", Void.class);
			}
			if(StringUtils.isEmpty(processNodeTimePostpone.getPjId())) {
				return MessageBean.create(Constant.MESSAGE_INT_FAIL, "pjId参数不能为空", Void.class);
			}
			PjProcessNodeTimePostponeMapper mapper = factory.getMapper(PjProcessNodeTimePostponeMapper.class);
			PjInfoMapper pjInfoMapper = factory.getMapper(PjInfoMapper.class);
			PjInfoBean pjInfo = pjInfoMapper.selectById(processNodeTimePostpone.getPjId());
			if(pjInfo == null) {
				return MessageBean.create(Constant.MESSAGE_INT_FAIL, "未找到对应的工程单", Void.class);
			}
			processNodeTimePostpone.setCreateInfo(userInfo);
			processNodeTimePostpone.setBillDate(new Date());
			processNodeTimePostpone.setBillNo(Tools.getBillNo(factory, "pj_process_node_time_postpone"));
			int iCount = mapper.insert(processNodeTimePostpone);
			if(iCount > 0) {
				
			}
			Map<String, String> data = new HashMap<String, String>();
			data.put("id", processNodeTimePostpone.getId());
			MessageBean<Map> message =MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "执行成功", Map.class);
			message.setData(data);
			return message;
		}catch(Exception e){
			logger.error("用户工程延期添加失败" + e.getMessage(), e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "用户工程延期添加失败", null);
		}*/
		return null;
	}
}
